package main

import (
	"fmt"
	"time"
)

func main() {
	count := make(chan int, 4)
	fin := make(chan struct{})
	go func() {
		defer func() {
			fin <- struct{}{}
		}()
		for i := 0; i < 10; i++ {
			count <- i + 100
			time.Sleep(time.Second)
		}
	}()
	// fmt.Println("count=", <-count)
	// fmt.Println("等信号", <-fin) // 阻塞等待信号
	// LooP:
	for {
		select {
		case <-fin:
			fmt.Println("结束了")
			// break LooP
			goto End
		case n := <-count:
			fmt.Println("count=", n)
		default:
			fmt.Println("如果以上通道都不满足，卡住了，default 执行，做事")
			time.Sleep(time.Second)
		}
	}
End:
	fmt.Println("$$$$$$$$$$$$$~~~~~~~~~~~~~~")
}
